package br.com.hermes.emu.bt.task;

import br.com.hermes.bt.HmHandle;
import br.com.hermes.emu.bt.EmuHandleCommListener;
import br.com.hermes.emu.bt.EmuMessage;

public class EmuTask extends Thread{
	
	private HmHandle handle;
	private int what;
	
	/**
	 * @param handle
	 * @param what
	 */
	public EmuTask(HmHandle handle, int what) {
		this.handle = handle;
		this.what = what;
	}
	/**
	 * @return the handle
	 */
	public HmHandle getHandle() {
		return handle;
	}
	/**
	 * @param handle the handle to set
	 */
	public void setHandle(HmHandle handle) {
		this.handle = handle;
	}
	/**
	 * @return the what
	 */
	public int getWhat() {
		return what;
	}
	/**
	 * @param what the what to set
	 */
	public void setWhat(int what) {
		this.what = what;
	}

	public void dispatchMessage(Object object){
		EmuHandleCommListener handleCommListener = (EmuHandleCommListener)this.getHandle().getTarget();
		handleCommListener.onTreatMessage(what, new EmuMessage(object));
	}
	
}
